 <template>
  <!-- 子组件2 -->
  <div>
    <img
      src="http://5b0988e595225.cdn.sohucs.com/images/20190901/734751f56f584979bb0bff9d13bfbd1c.jpeg"
      alt=""
      v-if="t || op"
    />
    <button @click="btn2">子组件B</button>
    <input type="text" placeholder="子组件B" v-model="msg" @keydown.13="dw()" />
  </div>
</template>
 <script>
import Bus from "@/bus.js";
export default {
  data() {
    return {
      t: "",
      arr: [
        { titele: "父传子", boo: false },
        { titele: "子传父", boo: false },
        { titele: "兄弟传参", boo: false },
      ],
      msg: "",
      op: "",
    };
  },
  methods: {
    btn2() {
      this.t = false;
    },
    dw() {
      Bus.$on("xs", (res) => {
        this.t = res;
      });
      this.arr.push({ titele: this.msg });
      this.msg = "";
    },
  },
  //   组件B
  mounted() {
    // Bus.$emit("cz", this.arr);
    this.$emit("cz",this.arr)
    Bus.$on("op", (res) => {
      this.op=res
    });
  },
  computed: {},
};
</script>
 <style lang='css' scoped>
* {
  margin: 0;
  padding: 0;
}
img {
  width: 600px;
  height: 600px;
  margin: 0 auto;
  position: fixed;
  left: 20%;
}
input {
  position: fixed;
  left: 100px;
  top: 20px;
  outline: none;
}
</style>